<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="header.jsp"%>
<script type="text/javascript" src="<%=path%>/scripts/My97DatePicker/WdatePicker.js"></script>
<div id="searchCondition2" class="tabCont phl ptm">
<div class="clear"></div>
	<div class="searchCondition" field="keywords">
		<span class="title">其他：</span>
		<input id="keywords" type="text" value="${keywords}" class="middleInput left" defaultText="地址关键字" />
		<input type="button" class="submitBtn left" value="" field="keywords" />
		<div class="clear"></div>
	</div>
<div class="searchCondition" field="houseType">
    <span class="title">户型：</span>
    <a class="noDistrict fco fwb" href="#">不限</a>
    <div class="districtCodition">
        <a class="fcbl" dataType="1"  data='1-0-0' href="#">1房</a>
        <a class="fcbl" dataType="2"  data='2-0-0' href="#">2房</a>
        <a class="fcbl" dataType="3"  data='3-0-0' href="#">3房</a>
        <a class="fcbl" dataType="4"  data='4-0-0' href="#">4房</a>
    </div>
    <input type="text"  id="roomDate" 		value="${room} " class="smallInput left" /><span class="prm left">房</span>
    <input type="text"  id="parlorDate"	 	value="${parlor}" class="smallInput left" /><span class="prm left">厅</span>
    <input type="text"  id="bathroomDate" 	value="${bathroom}" class="smallInput left" /><span class="prm left">卫</span>

    <input type="button" class="submitBtn left" value="" field="houseType" />
    <div class="clear"></div>
</div>
            	<div class="searchCondition" field="price">
                	<span class="title">价格：</span>
                    <a class="noDistrict fco fwb" href="#">不限</a>
                    <div class="districtCodition">
                    <a class="fcbl" dataType="5"  data='0-50' href="#">50万以下</a>
                    <a class="fcbl" dataType="6"  data='51-100' href="#">51-100万</a>
                    <a class="fcbl" dataType="7"  data='101-200' href="#">101万-200万</a>
                    <a class="fcbl" dataType="8"  data='200-0' href="#">200万以上</a>
                    </div>
                    <input type="text"  id="startinput" value="${start }" class="min smallInput left" /><span class="prm left">-</span>
                    <input type="text"  id="endinput" value="${end }" class="max smallInput left" /><span class="prm left">万</span>
                    <input type="button" class="submitBtn left" value="" field="price" />
                    <div class="clear"></div>
                </div>

<div class="pts">

    <div class="solidLine"></div>
    <p class="pvm">
        <b>当前找房条件：</b>
             <span id="currentCondition">
               <c:choose>
				<c:when test="${not empty dateTypeZW}">
					<b>价格：</b>
					<a field="dateType" title="移除此条件" class="closeBtnBlue fco mrm" href="#">
						${dateTypeZW }
					</a>
				</c:when>
				
				
				<c:when test="${not empty dateTypeZW}">
					<b>价格：</b>
					<a field="dateType" title="移除此条件" class="closeBtnBlue fco mrm" href="#">
						${dateTypeWZ }
					</a>
				</c:when>
				<c:otherwise>
					<c:if test="${not empty start or not empty end}">
						<b>价格：</b>
						<a field="price" title="移除此条件" class="closeBtnBlue fco mrm" href="#">
							<c:choose>
						 	<c:when test="${empty start}">不限</c:when>
							<c:otherwise>${start }</c:otherwise>
							</c:choose> 
							至
							<c:choose>
						 	<c:when test="${empty end}">不限</c:when>
							<c:otherwise>${end }</c:otherwise>
							</c:choose>
							万元
						</a>
					</c:if>
				</c:otherwise>
			</c:choose> 
			
			<c:if test="${not empty keywords}">
		    	<b>关键字：</b><a field="keywords" title="移除此条件" class="closeBtnBlue fco mrm" href="#">${keywords }</a>	
		    </c:if>		
			</span>
                        </span>
    </p>
</div>
</div>
<div class="tabBtm tabBtmLar"></div>
</div>

<div class="tabTop"></div>
<ul class="tab">
	<li class="left">
		<a publishType='0' class="tabFirst" href="<%=path %>/house/house-selllist.do">
			<span class="tabLeft"></span>
			<span class="tabCenter">房屋出售</span>
			<span class="tabRight"></span>
		</a>
	</li>
<!-- 	<li class="left"> -->
<!-- 		<a publishType='2' class="" href="/News/Comment"> -->
<!-- 			<span class="tabLeft"></span> <span class="tabCenter">评论</span> <span -->
<!-- 			class="tabRight"></span> -->
<!-- 	</a></li> -->
	<li class="clear"></li>

</ul>
<div class="clear"></div>
 <div class="tabCont pvs">
	<div class="homepageHouseList">
	<c:forEach var="item" items="${list}">  
		<ul class="houseList" onclick="window.open('<%=path %>/house/housecontent.do?nid=${item.hid }');" title="点击查看房源详情" >
	
   		<li class="houseListRight">
        	<div class="clearfix fcb">
           		 <div>
                <a href="<%=path %>/house/house-selllist.do?hid=${item.hid }" onclick="return false" class="houseTitle">${item.hname }</a>
            		</div>

            <div class="clear"></div>
            <div class="column column1">
                <p>
                    <span class="fwb fcbl">${item.address }</span>
                </p>
                <p>第${item.FLOOR }层/共${item.totalfloor }层</p>
            </div>
            <div class="column column2">
                <p>
                    <span class="fwb fcbl">${item.roomNum }房${item.parlorNum }厅${item.bathroomNum }卫</span>
                </p>
                <p>${item.area }平米</p>
            </div>
            <div class="column column3">
                <p><b class="fcbl">${item.price }万元</b></p>
            </div>

            <div class="column column4">
                <p>${item.year }年建成</p>
            </div>

            <div class="column column5">
                <p> ${item.userId }</p>
               
            </div>
        </div>
   	 </li>
   	 <li class="clear"></li>
	</ul>

</c:forEach>
<jmu:pager totalPage="${totalPage }" currentPage="${currentPage }"></jmu:pager>

</div>
<div class="clear"></div>
</div>
<div class="tabBtm"></div>
<script type="text/javascript">

        var newsType = '房屋故事';
        var keywords = '';
        var order = 'Id';
        var isAsc = false;
        var dateType = 0;
        // 新闻搜索
        function initSearchCondition2() {
            $(".submitBtn").bind("click", function () {
                var field = $(this).attr("field");
                if (field == 'keywords' && $("#keywords").val() != $("#keywords").attr("defaultText")) {
                    keywords = $("#keywords").val();
                }
                doSearchHouse();
                return false;
            });
                // change style
            // 绑定点击事件
            $("#searchCondition2 div.searchCondition a").bind("click", function () {
                // change style
                
                $(this).parents(".searchCondition").find(".noDistrict").removeClass("fco").removeClass("fwb").addClass("fcbl");
                $(this).parents(".searchCondition").find("a").removeClass("fco").removeClass("fwb");
                $(this).addClass("fco").addClass("fwb");
                var field = $(this).parents(".searchCondition").attr("field");
                var data = $(this).attr("data");
                dateType = $(this).attr("dataType");
                if (field == 'price') {
                    $("#startinput").val(data);
                    $("#endinput").val('');
                }
                else if (field == 'newsType') {
                    newsType = data;
                }
                else if (field == 'keywords') {
                    keywords = $("#keywords").val();
                }
                doSearchNews();
                return false;
            });
            $("#HasPicture").change(function () {
                doSearchNews();
            });
            $("a.OrderLink").click(function () {
                var newOrder = $(this).attr('data');
                if (newOrder != order) {
                    order = newOrder;
                    isAsc = "";
                }
                else if (!isAsc) {
                    isAsc = "true";
                }
                else {
                    order = '';
                    isAsc = '';
                }
                doSearchNews();
            });

            $("a.closeBtnBlue").click(function(){
                if($(this).hasClass("deleteComment"))
                {
                    // 避免与评论的删除按钮冲突
                    return;
                }
                var field = $(this).attr("field");
                if(field == "houseType")
                {
                    $("#roomDate").val("");
                    $("#parlorDate").val("");
                    $("#bathroomDate").val("");
                }
                else if(field == "price")
                {
                	 $("#startinput").val("");
                     $("#endinput").val("");
                }
                else if(field == "keywords")
                {
                    keywords = "";
                }
                
                doSearchNews();
                return false;
            });
        }

        function doSearchHouse() {
            var url = '<%=path%>/house/house-selllist.do?r=search';
            
        if ($("#startinput").val()) {
			url += "&start=" + $("#startinput").val();
		}
		if ($("#endinput").val()) {
			url += "&end=" + $("#endinput").val();
		}
		if($("#roomDate").val() ){
			url += "&room=" + $("#roomDate").val();
		}
		if($("#parlorDate").val()){
			url += "&parlor=" + $("#parlorDate").val();
		}
		if($("#bathroomDate").val()){
			url += "&bathroom=" + $("#bathroomDate").val();
		}
		if (dateType > 0) {
			url += "&dateType=" + dateType;
		}
		if (keywords) {
			url += "&keywords=" + encodeURI(encodeURI(keywords));
		}
		if ($("#HasPicture").attr("checked")) {
			url += "&hasPicture=true";
		}
		if (order && order != "Id") {
			url += "&order=" + order;
		}
		if (isAsc) {
			url += "&isAsc=" + isAsc;
		}
		window.location.href = url;
	}

	$(document).ready(function() {
		initSearchCondition2();
	});
</script>

<%@ include file="foot.jsp"%>